package com.example.wx.controller;

import com.example.wx.modle.req.WxPublicMainAddReqDTO;
import com.example.wx.modle.req.WxPublicMainStatusReqDTO;
import com.example.wx.modle.resp.WxPublicMainRespDTO;
import com.example.wx.other.ResponseDTO;
import com.example.wx.service.WxPublicMainService;
import com.example.wx.service.wx.WxService;
import com.vivo.it.vwkc.inventory.common.entity.request.CommonRequestPage;
import com.vivo.it.vwkc.inventory.common.entity.response.CommonResponsePage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 微信公众号主表
 *
 * @author ZhangBin
 * @date 2025-04-08 09:54:36
 * @Description:
 */
@Api("微信公众号主表")
@RestController
@RequestMapping("/wxPublic/main")
public class WxPublicMainController {
    @Autowired
    private WxPublicMainService wxPublicMainService;

    @Autowired
    private WxService wxService;

    @ApiOperation("分页查询")
    @PostMapping("/queryPage")
    public ResponseDTO<CommonResponsePage<?>> queryPage(@RequestBody @Valid CommonRequestPage commonRequestPage){
        wxPublicMainService.queryPage(commonRequestPage);
        return null;
    }

    @Deprecated
    @RequestMapping("/refreshAccessToken")
    public ResponseDTO<?> refreshAccessToken(@RequestBody @NotNull(message = "id不能为空")@RequestParam("id") Long id){
        wxService.refreshAccessToken(id);
        return ResponseDTO.success();
    }

    @ApiOperation("详情查询")
    @GetMapping("/queryDetail")
    public ResponseDTO<WxPublicMainRespDTO> queryDetail(@RequestBody @NotNull(message = "id不能为空")@RequestParam("id") Long id){
        return ResponseDTO.success(wxPublicMainService.queryDetail(id));
    }

    @ApiOperation("添加")
    @PostMapping("/add")
    public ResponseDTO<Boolean> add(@RequestBody @Valid WxPublicMainAddReqDTO wxPublicMainAddReqDTO){
        wxPublicMainService.add(wxPublicMainAddReqDTO);
        return ResponseDTO.success();
    }

    @ApiOperation("启用")
    @PostMapping("/enable")
    public ResponseDTO<Boolean> enable(@RequestBody @Valid WxPublicMainStatusReqDTO wxPublicMainStatusReqDTO){
        wxPublicMainService.enable(wxPublicMainStatusReqDTO);
        return ResponseDTO.success();
    }

    @ApiOperation("禁用")
    @PostMapping("/disable")
    public ResponseDTO<Boolean> disable(@RequestBody @Valid WxPublicMainStatusReqDTO wxPublicMainStatusReqDTO){
        wxPublicMainService.disable(wxPublicMainStatusReqDTO);
        return ResponseDTO.success();
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public ResponseDTO<Boolean> delete(@RequestBody @Valid WxPublicMainStatusReqDTO wxPublicMainStatusReqDTO){
        wxPublicMainService.delete(wxPublicMainStatusReqDTO);
        return ResponseDTO.success();
    }



}
